<?php
class WebApplication extends CWebApplication
{
    protected function init()
    {
        register_shutdown_function(array($this, 'onShutdownHandler'));
        parent::init();
    }

    public function onShutdownHandler()
    {
        $e=error_get_last();

        $errorsToHandle=E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING;

        if(!is_null($e) && ($e['type'] & $errorsToHandle)){
            $msg='Fatal error: '.$e['message'];
            // it's better to set errorAction = null to use system view "error.php" instead of run another controller/action (less possibility of additional errors)
            Yii::app()->errorHandler->errorAction=null;
            // handling error
            Yii::app()->handleError($e['type'], $msg, $e['file'], $e['line']);
        }
    }

    public function getParams()
    {
        return 'OK!!!';
    }
}